package com.mvd.app.ac2021.activitys;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
import com.kongzue.dialog.util.TextInfo;
import com.kongzue.dialog.v3.BottomMenu;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.R;
import com.mvd.app.ac2021.activitys.adapter.FormItemsAdapter;
import com.mvd.app.activity.BaseActivity;
import com.mvd.app.application.BaseApplication;
import com.mvd.app.commons.CommonUtils;
import com.mvd.app.commons.JsonUtil;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.SharedPreferencesUtils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.model.CarsInforModel;
import com.mvd.app.model.DetectItemModel;
import com.mvd.app.model.FormItemModel;
import com.mvd.app.model.UpdateCarInforModel;
import com.orhanobut.logger.Logger;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author Administrator
 * @version V1.0
 * @Title: UpdateCarActivity
 * @Package com.mvd.app.ac2021.activitys
 * @Description: 新后台，更新车辆-检测项目，信息
 * @date 2023-03-30 10:28
 **/

public class UpdateCarActivity extends BaseActivity implements AdapterView.OnItemClickListener {
    public UpdateCarActivity instances = null;
    @BindView(R.id.ac_update_lectronice_handbrake)
    TextView acUpdateLectroniceHandbrake;
    @BindView(R.id.ac_update_air_suspension)
    TextView acUpdateAirSuspension;
    @BindView(R.id.ac_update_suspension_form)
    TextView acUpdateSuspensionForm;
    @BindView(R.id.ac_update_mileage)
    EditText acUpdateMileage;
    @BindView(R.id.ac_update_layout_moreInfo)
    LinearLayout acUpdateLayoutMoreInfo;
    @BindView(R.id.ac_update_lv)
    ListView acUpdateLv;
    @BindView(R.id.ac_update_btn_refresh)
    Button acUpdateBtnRefresh;
    @BindView(R.id.ac_update_btn_upload)
    Button acUpdateBtnUpload;
    @BindView(R.id.ac_update_yingyun)
    EditText acUpdateYingyunZhenghao;

    private int CHECK_MODE = 0;//检测模式 0:外检  1：路试 2：底盘动态
    private String Line = "1";//外检车道
    private String Item_Code = "";//F1外检,R1路试，DC底盘动态
    private String Login_name = "", login_IDNumber;//当前登录的检测员的名字
    private CarsInforModel carsInforModel;
    private List<FormItemModel> formItemList = null, formItemList2 = new ArrayList<>(),
            refreshFormItemList = new ArrayList<>();
    private FormItemsAdapter formItemAdapter;
    private String detectItemt_data = "";//更新车辆信息--检测项目集合
    private boolean IsRefresh = false;//是否点击了刷新检测项目按钮

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_update_car);
        ButterKnife.bind(this);
        instances = this;
        setBackBtn();
        setTopTitle("更新车辆信息");
        String logStrf = "\n" + "onCreate-----更新车辆信息-----UpdateCarActivity---" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
        carsInforModel = (CarsInforModel) getIntent().getSerializableExtra("model_CarsInforModel");

        UtilsLog.e(carsInforModel.toString());
        Logger.e(carsInforModel.toString());
        login_IDNumber = getIntent().getExtras().getString("login_IDNumber", "");
        Login_name = getIntent().getExtras().getString("Login_name", "");
        CHECK_MODE = BaseApplication.JIANCE_MODE;
        switch (CHECK_MODE) {
            case 0:
                Item_Code = "F1";
                break;
            case 1:
                Item_Code = "R1";
                break;
            case 2:
                Item_Code = "DC";
                break;
        }

        getAllItemts();

        acUpdateYingyunZhenghao.setText(carsInforModel.getLicense());
        acUpdateMileage.setText(carsInforModel.getOdometer());
        //驻车制动是否使用电子控制装置
        if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
            acUpdateLectroniceHandbrake.setText(carsInforModel.getElectronicHandbrake().equals("1") ? "是" : "否");
        } else {
            acUpdateLectroniceHandbrake.setText("否");
        }

        //是否配备空气悬架
        if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getAirSuspension()))) {
            if (carsInforModel.getAirSuspension().equals("1")) {
                acUpdateAirSuspension.setText("是");
            } else {
                acUpdateAirSuspension.setText("否");
            }
        } else {
            acUpdateAirSuspension.setText("否");
        }
        //是否独立悬架
        if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getSuspensionForm()))) {
            if (carsInforModel.getSuspensionForm().equals("1")) {
                acUpdateSuspensionForm.setText("非独立悬架");
            } else {
                acUpdateSuspensionForm.setText("独立悬架");
            }
        } else {
            acUpdateSuspensionForm.setText("独立悬架");
        }
    }

    //初始化检测项目
    void initItems(List<CarsInforModel.DetectItemsBean> dtList) {
        UtilsLog.e("CarsInforModel.DetectItemsBean--长度===" + dtList.size());
        String dtlist_item="";
        for (int i = 0; i < dtList.size(); i++) {
            dtlist_item=dtlist_item+","+dtList.get(i).getItemCode();
        }
        String logStr = "\n" + "初始化检测项目----" + "\n" +
                "dtlist_item::" + dtlist_item+ "\n" ;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("CarsInforModel.DetectItemsBean--dtlist_item===" + dtlist_item);
        if (formItemList2 != null && formItemList2.size() > 0) {
            UtilsLog.e("formItemList--长度===" + formItemList2.size());
            for (int i = 0; i < dtList.size(); i++) {
                String itemCode = dtList.get(i).getItemCode();
                for (int j = 0; j < formItemList2.size(); j++) {
                    String code = formItemList2.get(j).getCode();
                    if (itemCode.equals(code)) {
                        formItemList2.get(j).setSelected(1);
//                        UtilsLog.e("itemCode==i==" + i + "===" + itemCode + "=========code==j==" + j + "===" + code);
                        break;
                    }
                }
            }

            formItemAdapter = new FormItemsAdapter(instances, formItemList2, null);
            acUpdateLv.setAdapter(formItemAdapter);
            acUpdateLv.setOnItemClickListener(this);
//            detectItemt_data = detectionItemData(formItemList2);
        } else {
            UtilsLog.e("formItemList2--nulll===");
        }
    }

    //所有检测项目
    private void getAllItemts() {
        String logStr = "\n" + "所有检测项目----" + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + NEW_ALL_ITEMTS;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("所有检测项目---url==" + SharedPreferencesUtils.getIP(this) + NEW_ALL_ITEMTS);
        OkGo.<String>get(SharedPreferencesUtils.getIP(this) + NEW_ALL_ITEMTS)
                .tag(this)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("所有检测项目-result==" + result);

                        String logStr = "\n" + "所有检测项目----请求成功" + "\n" +
                                "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        formItemList = new ArrayList<FormItemModel>();
                        formItemList2 = new ArrayList<FormItemModel>();
                        formItemList = JsonUtil.stringToArray(result, FormItemModel[].class);
                        formItemList2 = JsonUtil.stringToArray(result, FormItemModel[].class);
                        UtilsLog.e("formItemList2==" + formItemList2.size());
                        formItemAdapter = new FormItemsAdapter(instances, formItemList, null);
                        setListViewHeightBasedONChildren(acUpdateLv);
                        acUpdateLv.setAdapter(formItemAdapter);
                        acUpdateLv.setOnItemClickListener(instances);
//                        String str = result.substring(1, result.length() - 1);
//                        Toast.makeText(instances, "外检录像开始", Toast.LENGTH_LONG).show();

                        if (carsInforModel.getDetectItems() != null && carsInforModel.getDetectItems().size() > 0) {
                            UtilsLog.e("CarsInforModel.DetectItemsBean===" + carsInforModel.getDetectItems().toString());
                            initItems(carsInforModel.getDetectItems());
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "所有检测项目--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("所有检测项目-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    //刷新项目按钮，根据查询条件，判断车辆检测项目
    private void getRefreshItemts() {
        DetectItemModel model = new DetectItemModel();
//        DetectCategory，VehicleType，RegisteDate，HeadlightSystem，Category，ApprovedLoad，ParkingAxle，TotalAxis，TotalMass，CurbWeight，QIsSingle，UseProperty，ElectronicHandbrake，AirSuspension，SuspensionForm
        model.setDetectCategory(carsInforModel.getDetectCategory());
        model.setVehicleType(carsInforModel.getVehicleType());
        model.setRegisteDate(carsInforModel.getRegisteDate());
        model.setHeadlightSystem(carsInforModel.getHeadlightSystem());
        model.setCategory(carsInforModel.getCategory());
        model.setApprovedLoad(carsInforModel.getApprovedLoad());
        model.setParkingAxle(carsInforModel.getParkingAxle());
        model.setTotalAxis(String.valueOf(carsInforModel.getTotalAxis()));
        model.setTotalMass(String.valueOf(carsInforModel.getTotalMass()));
        model.setCurbWeight(String.valueOf(carsInforModel.getCurbWeight()));
        model.setQIsSingle(String.valueOf(carsInforModel.getQIsSingle() != "" ? carsInforModel.getQIsSingle() : 1));
        model.setUseProperty(carsInforModel.getUseProperty());

        model.setElectronicHandbrake(
                String.valueOf(acUpdateLectroniceHandbrake.getText().toString().trim().equals("是") ? 1 : 0));
        model.setAirSuspension(String.valueOf(acUpdateAirSuspension.getText().toString().trim().equals("是") ? 1 : 0));
        model.setSuspensionForm(String.valueOf(acUpdateSuspensionForm.getText().toString().trim().equals("独立悬架") ? 0 : 1));

        Gson gson = new Gson();
        String json = gson.toJson(model);
        String logStr = "\n" + "刷新检测项目----" + "\n" +
                "json==" + json + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + NEW_REFRESH_ITEMTS;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("刷新检测项目---json==" + json);
        UtilsLog.e("刷新检测项目---url==" + SharedPreferencesUtils.getIP(this) + NEW_REFRESH_ITEMTS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + NEW_REFRESH_ITEMTS)
                .tag(this)
                .upJson(json)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("刷新检测项目-result==" + result);
                        IsRefresh = true;
                        String logStr = "\n" + "刷新检测项目----请求成功" + "\n" +
                                "result::" + response.body() + "\n" ;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
//                        refreshFormItemList = new ArrayList<>();
//                       boolean addSuccess= refreshFormItemList.addAll(formItemList);
//                        UtilsLog.e("是否添加成功==" + addSuccess);
                        for (int i = 0; i < formItemList.size(); i++) {
                            if (result.contains(formItemList.get(i).getCode())) {
                                formItemList.get(i).setSelected(1);
//                                UtilsLog.e("ii==" + i + "=========code" + formItemList.get(i).getCode());
                            }
                        }
                        formItemAdapter = new FormItemsAdapter(instances, formItemList, null);
                        acUpdateLv.setAdapter(formItemAdapter);
                        acUpdateLv.setOnItemClickListener(instances);
//                        formItemAdapter.notifyDataSetInvalidated();
//                        detectItemt_data = detectionItemData(formItemList);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        IsRefresh = false;
                        String logStr2 = "\n" + "刷新检测项目--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("刷新检测项目-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    private String[] fou_shi_str = new String[]{"否", "是"};
    private String[] suspension_form = new String[]{"独立悬架", "非独立悬架"};

    private void showMyDialog(String[] str, final int id) {
//        BottomMenu bottomMenu= BottomMenu().build(this);
        BottomMenu.show(this, str, new OnMenuItemClickListener() {
            @Override
            public void onClick(String text, int index) {
                //返回参数 text 即菜单名称，index 即菜单索引
                UtilsLog.e("外检---showMyDialog==" + text + "===" + index);
                switch (id) {
                    case R.id.ac_update_air_suspension:
                        //空气悬架
                        acUpdateAirSuspension.setText(text);
                        break;
                    case R.id.ac_update_suspension_form:
                        //悬架类型
                        acUpdateSuspensionForm.setText(text);
                        break;
                    case R.id.ac_update_lectronice_handbrake:
                        //电子手刹
                        acUpdateLectroniceHandbrake.setText(text);
                        break;
//                    case R.id.ac_car_tv_beizhu_more:
//                        //备注
//                        acCarBeizhu.setText(text);
//                        break;
                }
            }
        }).setMenuTextInfo(new TextInfo().setBold(true).setFontColor(Color.BLACK).setGravity(Gravity.CENTER));
    }

    @OnClick({R.id.ac_update_lectronice_handbrake, R.id.ac_update_air_suspension, R.id.ac_update_suspension_form, R.id.ac_update_layout_moreInfo,
            R.id.ac_update_btn_refresh, R.id.ac_update_btn_upload})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ac_update_btn_refresh:
                //刷新项目按钮，根据查询条件，判断车辆检测项目

                getAllItemts();
                Handler handler=new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        getRefreshItemts();
                    }
                },400);

                break;
            case R.id.ac_update_btn_upload:
                updateCarInforsData();
                break;
            case R.id.ac_update_lectronice_handbrake:
                showMyDialog(fou_shi_str, R.id.ac_update_lectronice_handbrake);
                break;
            case R.id.ac_update_air_suspension:
                showMyDialog(fou_shi_str, R.id.ac_update_air_suspension);
                break;
            case R.id.ac_update_suspension_form:
                showMyDialog(suspension_form, R.id.ac_update_suspension_form);
                break;
            case R.id.ac_update_layout_moreInfo:
                break;
        }
    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        FormItemsAdapter.ViewHolder viewHolder = (FormItemsAdapter.ViewHolder) view.getTag();
        if (viewHolder.mCheckBox.isChecked()) {
            viewHolder.mCheckBox.setChecked(false);
//            viewHolder.mCheckBox.setBackground(instances.getResources().getDrawable(R.drawable.i_no));
            UtilsLog.e("mCheckBox", position + "==取消了选择");
            if (IsRefresh) {
                formItemList.get(position).setSelected(0);
            } else {
                formItemList2.get(position).setSelected(0);
            }

        } else {
            viewHolder.mCheckBox.setChecked(true);
//            viewHolder.mCheckBox.setBackground(instances.getResources().getDrawable(R.drawable.i_hege));
            if (IsRefresh) {
                formItemList.get(position).setSelected(1);
            } else {
                formItemList2.get(position).setSelected(1);
            }
            UtilsLog.e("mCheckBox", position + "==选择");
        }
    }


    public static void setListViewHeightBasedONChildren(ListView listView) {
        ListAdapter listAdapter = listView.getAdapter();
        if (listAdapter == null) {
            return;
        }
        int totalHeight = 0;
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }
        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(params);
    }

    //更新车辆信息接口
    private void updateCarInforsData() {
        UpdateCarInforModel model = new UpdateCarInforModel();
        model.setCarNO(carsInforModel.getCarNO());
        model.setDetectQueueID(String.valueOf(carsInforModel.getID()));
        model.setGUID(carsInforModel.getGUID());
        model.setTimes(String.valueOf(carsInforModel.getTimes()));
        model.setPlatformSN(carsInforModel.getSN());
        model.setOdometer(acUpdateMileage.getText().toString().trim() != "" ? acUpdateMileage.getText().toString().trim() : carsInforModel.getLicense());
        model.setLicense(acUpdateYingyunZhenghao.getText().toString().trim() != "" ? acUpdateYingyunZhenghao.getText().toString().trim() : carsInforModel.getOdometer());
        detectItemt_data = detectionItemData();
        model.setDetectionItem(detectItemt_data);
        model.setCategory(carsInforModel.getCategory());
        model.setEngineNO(carsInforModel.getEngineNO());
        model.setBodyColor(carsInforModel.getBodyColor());
        model.setValidTill(carsInforModel.getValidTill());
        model.setExpirationDate(carsInforModel.getExpirationDate());
        model.setFuelType(carsInforModel.getFuelType());
        model.setUseProperty(carsInforModel.getUseProperty());
        model.setPower(String.valueOf(carsInforModel.getPower()));
        model.setTotalAxis(String.valueOf(carsInforModel.getTotalAxis()));
        model.setTotalMass(String.valueOf(carsInforModel.getTotalMass()));
        model.setCurbWeight(String.valueOf(carsInforModel.getCurbWeight()));
        model.setProductionDate(carsInforModel.getProductionDate());
        model.setBrand(carsInforModel.getBrand());
        model.setCarModel(carsInforModel.getCarModel());
        model.setProductionEnterprises(carsInforModel.getProductionEnterprises());
        model.setOwner(carsInforModel.getOwner());
        model.setVehicleType(carsInforModel.getVehicleType());
        model.setUsage(carsInforModel.getUsage());
        model.setUseAttribute(carsInforModel.getUseAttribute());
        model.setUnderpanType(carsInforModel.getUnderpanType());
        model.setParkingAxle(carsInforModel.getParkingAxle());
        model.setParkingAxis(String.valueOf(carsInforModel.getParkingAxis()));
        model.setMainAxis(String.valueOf(carsInforModel.getMainAxis()));
        model.setBrakeForce(carsInforModel.getBrakeForce());
        model.setHeadlightSystem(carsInforModel.getHeadlightSystem());
        model.setCentralAxle(carsInforModel.getCentralAxle());
        model.setParallelModel(carsInforModel.getParallelModel());
        model.setElectronicHandbrake(
                String.valueOf(acUpdateLectroniceHandbrake.getText().toString().trim().equals("是") ? 1 : 0));
        model.setAirSuspension(String.valueOf(acUpdateAirSuspension.getText().toString().trim().equals("是") ? 1 : 0));
        model.setSuspensionForm(String.valueOf(acUpdateSuspensionForm.getText().toString().trim().equals("独立悬架") ? 0 : 1));
        model.setPlateType(carsInforModel.getPlateType());
        model.setPlateRegion(carsInforModel.getPlateRegion());
        model.setCarNO(carsInforModel.getCarNO());
        model.setVIN(carsInforModel.getVIN());

        Gson gson = new Gson();
        String json = gson.toJson(model);
        String logStr = "\n" + "更新车辆信息接口----" + "\n" + "json==" + json + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + NEW_UPDATE_INFORS;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("更新车辆信息接口---json==" + json);
        UtilsLog.e("更新车辆信息接口---url==" + SharedPreferencesUtils.getIP(this) + NEW_UPDATE_INFORS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + NEW_UPDATE_INFORS)
                .tag(this)
                .upJson(json)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("更新车辆信息接口-result==" + result);
                        String logStr = "\n" + "更新车辆信息接口----请求成功" + "\n" +
                                "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);

                        if (result.equalsIgnoreCase("ok")) {
                            Toast.makeText(instances, "更新车辆信息成功", Toast.LENGTH_LONG).show();
                            instances.finish();
                        }
//                        for (int i = 0; i < formItemList.size(); i++) {
//                            if(result.contains(formItemList.get(i).getCode())){
//                                formItemList.get(i).setSelected(1);
//                                UtilsLog.e("ii=="+i+"=========code"+formItemList.get(i).getCode());
//                            }
//                        }
//                        formItemAdapter=new FormItemsAdapter(instances,formItemList,null);
//                        acUpdateLv.setAdapter(formItemAdapter);
//                        acUpdateLv.setOnItemClickListener(instances);
//                        formItemAdapter.notifyDataSetInvalidated();
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "更新车辆信息接口--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("更新车辆信息接口-onError==" + response.body());
                        Toast.makeText(instances, "更新车辆信息失败", Toast.LENGTH_LONG).show();
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    String detectionItemData() {
        UtilsLog.e("IsRefresh==" + IsRefresh);
        String result = "";
        List<FormItemModel> list = new ArrayList<>();
        if (IsRefresh) {
            list = formItemList;
        } else {
            list = formItemList2;
        }
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getSelected() == 1) {
                result = result + list.get(i).getCode() + ",";
            }
        }
        UtilsLog.e("result==" + result);
        UtilsLog.e("result=-1=" + result.substring(0, result.length() - 1));
        String logStr = "\n" + "更新车辆信息接口---detectionItemData--" + "\n" +
                "IsRefresh==" + IsRefresh + "\n" +
                "formItemList==" + formItemList.toString() + "\n" +
                "formItemList2==" + formItemList2.toString() + "\n" +
                "result==" + result.substring(0, result.length() - 1);
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        return result.substring(0, result.length() - 1);
    }
}
